package com.qyl.honghengshop.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.qyl.honghengshop.dao.BaseDao;
import com.qyl.honghengshop.dao.CommentDao;
import com.qyl.honghengshop.dto.Comment;
import com.qyl.honghengshop.mapper.CommentMapper;
import com.qyl.honghengshop.mapper.GoodsTypeMapper;

public class CommentDaoImpl extends BaseDao implements CommentDao {

	@Override
	public int addComment(Comment comment) {
		
		SqlSession sqlSession = this.getSqlSession();
		
		CommentMapper commentMapper = sqlSession.getMapper(CommentMapper.class);
		
		int count = commentMapper.addComment(comment);
		
		sqlSession.commit();
		
		this.closeSqlSession();
		
		return count;
	}

	@Override
	public List<Comment> getCommentList(Integer id) {

		SqlSession sqlSession = this.getSqlSession();
		
		CommentMapper commentMapper = sqlSession.getMapper(CommentMapper.class);
		
		List<Comment> commentList = commentMapper.getCommentList(id);

		this.closeSqlSession();
		
		return commentList;
	}

}
